# аналог БД
class User:
    # вместо списка, согласно заданию, удобнее использовать словарь,
    # где ключ = id пользователя, а значение - сам экземпляр User
    Users = dict()
    Numerator = 0

    def __init__(self, id, nickname, email, password):
        self.id = id
        self.nickname = nickname
        self.email = email
        self.password = password

    @classmethod
    def Create(cls, nickname, email, password):
        AllUsers = cls.Users.values()

        for CurrentUser in AllUsers:
            if CurrentUser.email == email or CurrentUser.nickname == nickname:
                return None

        NewUserObject = User(cls.Numerator, nickname, email, password)
        cls.Numerator = cls.Numerator + 1
        cls.Users[NewUserObject.id] = NewUserObject

        return NewUserObject.Serialize()

    @classmethod
    def Read(cls, id):
        UserObject = cls.Users.get(id)

        if UserObject is None:
            result = None
        else:
            result = UserObject.Serialize()

        return result

    @classmethod
    def Update(cls, id, nickname, email, password):
        UserObject = cls.Users.get(id)

        if UserObject is None:
            return None

        UserObject.nickname = nickname
        UserObject.email = email
        UserObject.password = password

        return UserObject.Serialize()

    @classmethod
    def Delete(cls, id):
        return cls.Users.pop(id) is not None

    @classmethod
    def List(cls):
        return [CurrentUser.Serialize() for CurrentUser in cls.Users.values()]

    def Serialize(self):
        return {"id": self.id, "nickname": self.nickname, "email": self.email}
